package com.cy.pj.module.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ModelAndViewController {
    @RequestMapping("/doModelAndView")
    public String doModeAndView(Model model){
        model.addAttribute("name", "Json");
        model.addAttribute("state", "OK");
        return "view";
    }
    @RequestMapping("/doModelAndView2")
    public ModelAndView doModelAndView2(ModelAndView modelAndView){
        modelAndView.addObject("name","Json");
        modelAndView.addObject("state",true);
        modelAndView.setViewName("view");// /templates/model/view.html
        return modelAndView;//这里的modelAndView是model对象和view对象的一个合体
    }
}
